package com.userfactssample.client.client.screens;

import com.smartgwt.mobile.client.data.Record;
import com.smartgwt.mobile.client.data.RecordList;
import com.smartgwt.mobile.client.types.SelectionStyle;
import com.smartgwt.mobile.client.types.TableMode;
import com.userfactssample.client.client.common.FontDecorator;
import com.userfactssample.client.client.framework.UMHeader2;
import com.userfactssample.client.client.framework.UMTableView;
import com.userfactssample.client.client.framework.UMVLayout;

public class QuestionScreen extends AbstractUMScreen{
	@Override
	public void buildMainScreen(UMVLayout container) {
		UMHeader2 header = new UMHeader2("What is your intended<br />purpose of visit ?<br/>To Demo Single Selection with Tick Marks");
		FontDecorator.decorateAsHeading(header);
		container.addMember(header);
		
		UMTableView tableView = new UMTableView();
		tableView.setTitleField("option");
		tableView.setSelectionType(SelectionStyle.SINGLE);
		tableView.setShowSelectedIcon(true);
		tableView.setTableMode(TableMode.PLAIN);
		tableView.setData(getRecords());
		
//		tableView.addSelectionChangedHandler(new SelectionChangedHandler() {
//
//	            @Override
//	            public void onSelectionChanged(SelectionEvent event) {
//	                if (event.getState()) {
//	                }
//	            }
//	        });
		container.addMember(tableView);		
	}

	private RecordList getRecords() {
		RecordList list = new RecordList();
		
		Record record = new Record();
		record.setAttribute("option", "To Shop");
		record.setAttribute("_id", 0);
		list.add(record);
		
		record = new Record();
		record.setAttribute("option", "To Browse");
		record.setAttribute("_id", 1);
		list.add(record);
		
		record = new Record();
		record.setAttribute("option", "Get Support");
		record.setAttribute("_id", 2);
		list.add(record);
		
		record = new Record();
		record.setAttribute("option", "Haven't decided yet");
		record.setAttribute("_id", 3);
		list.add(record);
		
		return list;
	}
}
